import { Resolver, Query, Mutation } from '@nestjs/graphql'
import { SmsService } from './sms.service'
import { Sms } from './sms.entity'
@Resolver('Sms')
export class SmsResolver {
  constructor(private sms: SmsService) {}

  @Query('smses')
  async getSmsList(): Promise<Sms[]> {
    return await this.sms.getSmsList()
  }

  @Query('smsTodaySuccessTotal')
  async smsTodaySuccessTotal(): Promise<number> {
    return await this.sms.smsTodaySuccessTotal()
  }

  @Query('smsMonthSuccessTotal')
  async smsMonthSuccessTotal(): Promise<number> {
    return await this.sms.smsMonthSuccessTotal()
  }

  @Query('smsTodayTotal')
  async smsTodayTotal(): Promise<number> {
    return await this.sms.smsTodayTotal()
  }

  @Query('smsMonthTotal')
  async smsMonthTotal(): Promise<number> {
    return await this.sms.smsMonthTotal()
  }

  @Query('settings')
  async settings() {
    return []
  }

  @Mutation('sendSmsCode')
  async sendSmsCode(_, { mobile }): Promise<Sms> {
    return await this.sms.sendSmsCode(mobile)
  }
}
